package com.sl.au.repository;

import java.util.Date;
import java.util.List;

import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;

import com.sl.au.entity.ViewForVisitorReward;
import com.sl.au.entity.VisitorReward;
import com.sl.au.entity.VisitorRewardProcessing;

public interface VisitorRewardProcessingRepository extends JpaRepository<VisitorRewardProcessing, String> {
	
	@Query("select u from VisitorRewardProcessing u where ( u.details like %?1% or u.redeemCode like %?1% ) and u.user.id=?2 ")
	Page<VisitorRewardProcessing> getPageBykey(String key,String userId, Pageable pageable);
	
	@Query("select count(u) from VisitorRewardProcessing u where ( u.details like %?1% or u.redeemCode like %?1% ) and u.user.id=?2 ")
	int getPageBykeyCount(String key,String userId);

	@Query("select u from VisitorRewardProcessing u where u.user.id=?1 ")
	Page<VisitorRewardProcessing> getPage(String userId, Pageable pageable);
	
	@Query("select count(u) from VisitorRewardProcessing u where u.user.id=?1 ")
	int getPageCount(String userId);
	
	@Query("select u from VisitorRewardProcessing u where u.redeemCode is not null and u.user.id=?1 order by u.operationTime desc")
	List<VisitorRewardProcessing> getExchangeDetail(String userId);
}
